package com.haiheng.common.fragment

import android.content.Context
import com.haiheng.common.activity.RouterActivity
import com.haiheng.library_base.fragment.BaseFragment
import com.haiheng.library_base.http.HttpRequest
import com.haiheng.library_base.http.HttpResponse
import me.jessyan.autosize.AutoSize
import me.jessyan.autosize.AutoSizeCompat

/**
 *
 * @Des:
 * @Author: hwz
 * @Date:2022/4/18 0018
 * @Version: 1.0
 */
abstract class RouterFragment :BaseFragment() {

    lateinit var activity:RouterActivity

    /**
     * 获取RouterActivity方便调用navigation进行页面切换
     */
    override fun onAttach(context: Context) {
        AutoSize.autoConvertDensity(getActivity(), 600f, true);
        super.onAttach(context)
        activity = context as RouterActivity
    }

    /**
     * 网络请求结果处理（不建议封装在网络请求框架中）
     */
    fun <T:HttpResponse> httpParseSuccess(result: T,success:((T) -> Unit)){
        activity.httpParseSuccess(result,success)
    }
}